Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RcloneProvider: Block rename, copy, and move while source file is open #90

Merged
merged 1 commit into from
Oct 25, 2024

Conversation

chenxiaolong
Copy link
Owner

Android's StorageManager.openProxyFileDescriptor() makes it impossible to have a blocking close() call from the client's point of view. This causes problems with client apps that write data to a temporary file and then rename it when complete. Rclone's VFS cache writeback process fails if a file gets renamed while it is being uploaded.

Since the asynchronicity of close() is something we're stuck with, the best we can do is make other operations blocking. RcloneProvider now tracks which files are open for writing and forces the rename, copy, and move operations to wait if the source file is one of the open files or any of its parent directories. This is sufficient to make common file access patterns work, but if a client app tries to shoot itself in the foot, it can absolutely still do so.

Fixes: #81

Android's StorageManager.openProxyFileDescriptor() makes it impossible
to have a blocking close() call from the client's point of view. This
causes problems with client apps that write data to a temporary file and
then rename it when complete. Rclone's VFS cache writeback process fails
if a file gets renamed while it is being uploaded.

Since the asynchronicity of close() is something we're stuck with, the
best we can do is make other operations blocking. RcloneProvider now
tracks which files are open for writing and forces the rename, copy, and
move operations to wait if the source file is one of the open files or
any of its parent directories. This is sufficient to make common file
access patterns work, but if a client app tries to shoot itself in the
foot, it can absolutely still do so.

Fixes: #81

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
@chenxiaolong chenxiaolong self-assigned this Oct 25, 2024
chenxiaolong added a commit that referenced this pull request Oct 25, 2024
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
@chenxiaolong chenxiaolong merged commit 41a1c1e into master Oct 25, 2024
1 check passed
@chenxiaolong chenxiaolong deleted the async-close-workaround branch October 25, 2024 03:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

renameDocument Problem
1 participant